// 引入vue
import Vue from "vue";
//引入router
import VueRouter from 'vue-router'
//使用router
Vue.use(VueRouter)

//解决vue路由重复导航错误
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
	mode: 'hash', //默认哈希(hash):兼容性好,可选history:兼容性略差
	routes: [{
		path: '/',
		redirect: '/home',
		meta: {
			title: '首页',
		},
	}, {
		path: '/home',
		name: 'home',
		component: () => import('@/views/home.vue'),
		meta: {
			title: '首页',
		},
	}, {
		path: '/news',
		name: 'news',
		component: () => import('@/views/news.vue'),
		meta: {
			title: '扶贫新闻',
		},
	}, {
		path: '/newsdetails',
		name: 'newsdetails',
		component: () => import('@/views/newsdetails.vue'),
		meta: {
			title: '扶贫新闻详情',
		},
	}, {
		path: '/shop',
		name: 'shop',
		component: () => import('@/views/shop.vue'),
		meta: {
			title: '扶贫商品',
		}
	}, {
		path: '/shopdetails',
		name: 'shopdetails',
		component: () => import('@/views/shopdetails.vue'),
		meta: {
			title: '扶贫商品详情',
		},
	}, {
		path: '/support',
		name: 'support',
		component: () => import('@/views/support.vue'),
		meta: {
			title: '扶贫资助',
		},
	}, {
		path: '/supportdetails',
		name: 'supportdetails',
		component: () => import('@/views/supportdetails.vue'),
		meta: {
			title: '扶贫资助详情',
		},
	}, {
		path: '/personal',
		name: 'personal',
		component: () => import('@/views/personal.vue'),
		meta: {
			title: '个人中心',
		},
	}]
})

export default router
